import pandas as pd
import numpy as np


def write_hdf5():
    frame = pd.DataFrame(np.arange(20).reshape(4,5),
                         columns=['white', 'red', 'blue', 'black', 'green'])
    print(frame)
    frame.to_hdf(path_or_buf="D:\\learn_and_test_data\\hdf5_test.h5", key="color", format="table", append=True)


def read_hdf5():
    frame = pd.read_hdf(path_or_buf="D:\\learn_and_test_data\\hdf5_test.h5", key="color")
    print(frame)


if __name__ == '__main__':
    write_hdf5()
    read_hdf5()
